// stores/chatStore.ts
import { defineStore } from 'pinia';

export const aiTopic = defineStore('chat', {
  state: () => ({
    fullResponse: '',       // 存储完整响应
    isLoading: false,       // 加载状态
    messageList: [],        // 消息列表
    questions: [] as any[], // 解析后的题目
  }),
  
  actions: {
    setFullResponse(response: string) {
      this.fullResponse = response;
    },
    
    setLoading(status: boolean) {
      this.isLoading = status;
    },
    
    addMessage(message: any) {
      this.messageList.push(message);
    },
    
    setQuestions(questions: any[]) {
      this.questions = questions;
    },
    
    clearMessages() {
      this.messageList = [];
    }
  }
});